package com.example.service.impl;

import com.example.entity.po.User;
import com.example.mapper.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class UserServiceImpl {

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private RedisTemplate<String,Object> redisTemplate;

    /**
     * 根据用户id查询用户信息
     * @param id
     * @return
     */
    public User selectById(Integer id){
        return userMapper.selectByPrimaryKey(id);
    }

    @Cacheable("name")
    public User selectById1(Integer id){
        return userMapper.selectByPrimaryKey(id);
    }
}
